/**
 * Author: 冯亮亮
 * Remark: 采购计划
 */
lyfdefine(['echarts', 'time-line', 'common/scm-plan-common-choosegoods'], function (echarts, time, scmPlanCommonChoosegoods) {
    return ({
            data: function () {
                return {
                    chooseGoodsDialog: false,
                    tableData: [],
                    dataList: [],
                    multipleSelection: [],           // 列表中被勾选的多选框
                    dialogVisible: false,
                    dialogFormVisible: false,
                    value10: false,
                    activeStep: 1,
                    cancelBtnText: '取消',
                    tableShow: true,
                    updateFrom: [],
                    //taga: false, //导入按钮隐藏
                    echartsLoading: false,
                    fileList: [],
                    importErrInfo: '',//导入校验失败信息
                    pickerOptions: {
                        shortcuts: [{
                            text: '最近一周',
                            onClick(picker) {
                                const nowDate = new Date();
                                const oneWeekDate = new Date(nowDate - 7 * 24 * 3600 * 1000);
                                let nowDayOfWeek = oneWeekDate.getDay(); // 本周的第几天
                                let nowDay = oneWeekDate.getDate(); // 当前日
                                let nowMonth = oneWeekDate.getMonth(); // 当前月
                                let nowYear = oneWeekDate.getFullYear(); // 当前年
                                let start = new Date(nowYear, nowMonth, nowDay - (nowDayOfWeek === 0 ? 7 : nowDayOfWeek) + 1)
                                let end = new Date(nowYear, nowMonth, nowDay - (nowDayOfWeek === 0 ? 7 : nowDayOfWeek) + 7)
                                picker.$emit('pick', [start, end]);
                            }
                        }, {
                            text: '最近一个月',
                            onClick(picker) {
                                let start = new Date();
                                start.setMonth(start.getMonth() - 1);
                                start.setDate(1);
                                const end = new Date();
                                let oneDay = 3600 * 1000 * 24
                                end.setDate(1)
                                end.setTime(end.getTime() - oneDay)
                                picker.$emit('pick', [start, end]);
                            }
                        }, {
                            text: '最近三个月',
                            onClick(picker) {
                                let start = new Date();
                                start.setMonth(start.getMonth() - 3);
                                start.setDate(1);
                                const end = new Date();
                                let oneDay = 3600 * 1000 * 24
                                end.setDate(1)
                                end.setTime(end.getTime() - oneDay)
                                picker.$emit('pick', [start, end]);
                            }
                        }]
                    },
                    charts: false,
                    cType: false,
                    checked: false,
                    a: '',
                    dialogVisible1: false,
                    dialogVisible3: false,
                    dateList: [],
                    exportTime: '',
                    tables: [],
                    //1:导入数据人权限，2:渠道人权限，3:全渠道人权限
                    levels: '',
                    //高级搜索里计划类型集合
                    otherTypeLists: [],
                    //导入里计划类型集合
                    otherImpTypeLists: [],
                    festivals: [],
                    weekDate: [],
                    needMergeArr: [], // 有合并项的列
                    rowMergeArrs: {},
                    titleText: '导入引导',
                    pageIndex: 1,
                    pageSize: 10,
                    totalPage: 0,
                    totalCount: 0,
                    props1: {
                        checkStrictly: true,
                        multiple: true,
                        label: 'name',
                        value: 'code',
                        lazy: true,
                        lazyLoad: this.lazyLoad1
                    },
                    props2: {
                        checkStrictly: true,
                        multiple: true,
                        label: 'name',
                        value: 'code',
                        lazy: true,
                        lazyLoad: this.lazyLoad2
                    },
                    props3: {
                        checkStrictly: true,
                        multiple: true,
                        label: 'name',
                        value: 'code',
                        lazy: true,
                        lazyLoad: this.lazyLoad3
                    },
                    defaultUnit: '',
                    defaultUnitItem: {
                        name: '销售单位',
                        type: 2
                    },
                    dataForm: {
                        startTime: '',
                        quota1: [],
                        quota11: [],
                        layeredCodess: [],
                        unitType: 2
                    },
                    dataListLoading: false,
                    targetOption: [],
                    lastConfirmedQtyList: [],
                    targetOption1: [
                        {
                            label: '上次计划量',
                            value: 1
                        }, {
                            label: '上次确认量',
                            value: 2
                        }, {
                            label: '计划量',
                            value: 3
                        }, {
                            label: '确认量',
                            value: 4
                        }, {
                            label: '计划与确认差值',
                            value: 5
                        }, {
                            label: '计划与确认比例',
                            value: 6
                        }, {
                            label: '实际销量',
                            value: 7
                        }
                    ],
                    targetOption2: [
                        {
                            label: '上次计划量',
                            value: 1
                        }, {
                            label: '上次确认量',
                            value: 2
                        }, {
                            label: '计划量',
                            value: 3
                        }, {
                            label: '下级确认量',
                            value: 4
                        }, {
                            label: '确认量',
                            value: 5
                        }, {
                            label: '计划与确认差值',
                            value: 6
                        }, {
                            label: '计划与确认比例',
                            value: 7
                        }, {
                            label: '实际销量',
                            value: 8
                        }
                    ],

                    currentPage4: '',
                    unitOption: [],
                    values: [],
                    importStatus: true,
                    confirmStatus:false,
                    valuea: [],
                    value1: ['计划量', '确认量', '计划与确认比例'],
                    value2: ['下级确认量', '计划量', '确认量', '计划与确认比例'],
                    labels: [],
                    label1: [
                        "上次计划量",
                        "上次确认量",
                        "计划量",
                        "确认量",
                        "计划与确认差值",
                        "计划与确认比例",
                        "实际销量"
                    ],
                    label2: [
                        "上次计划量",
                        "上次确认量",
                        "下级确认量",
                        "计划量",
                        "确认量",
                        "计划与确认差值",
                        "计划与确认比例",
                        "实际销量"
                    ]
                }
            },
            components: {
                scmPlanCommonChoosegoods
            },
            mounted() {
                let _this = this
                //校验系统配置的时间 导入、确认按钮开启，其他时间禁用
                _this.getImportTime()
                _this.getConfirmTime()
                let beginOflastWeek = _this.getBeginOflastWeek()
                _this.dataForm.unitType = _this.defaultUnitItem.type
                _this.dataForm.startTime = beginOflastWeek
                _this.getOtherLevel()
                _this.getDataList()
                _this.getHolidays()
                _this.getUnit()

            },
            methods: {
                initOption() {
                    //全渠道用户
                    if (this.levels == 2) {
                        //指标多一个下级确认量
                        this.targetOption = this.targetOption2
                        this.values = this.value2
                        this.labels = this.label2
                    }
                    //渠道用户和下级
                    else  {
                        //导入按钮显示(系统配置)
                        //this.taga = true
                        this.targetOption = this.targetOption1
                        this.values = this.value1
                        this.labels = this.label1
                    }
                },
                getImportTime() {
                    this.$http({
                        url: 'scm-plan-admin/api/v1/salesPlanOther/getImportTime',
                        method: 'get'
                    }).then(result => {
                        let time = result.data.data
                        time = time.split(",");
                        console.log(time)
                        let date = new Date();
                        time.forEach(item =>{
                            if (date.getDay() == item) {
                                this.importStatus = false
                            }
                        })
                    })
                },
                getConfirmTime() {
                    this.$http({
                        url: 'scm-plan-admin/api/v1/salesPlanOther/getConfirmTime',
                        method: 'get'
                    }).then(result => {
                        let time = result.data.data
                        time = time.split(",");
                        console.log(time)
                        let date = new Date();
                        time.forEach(item =>{
                            if (date.getDay() == item) {
                                this.confirmStatus = true
                            }
                        })
                    })
                },
                getOtherLevel() {
                    this.$http({
                        url: 'scm-plan-admin/api/v1/salesPlanOther/getOtherPlanLevel',
                        method: 'post',
                    }).then(result => {
                        this.levels = result.data.data
                        this.initOption()
                    })
                },
                getHolidays() {
                    this.$http({
                        url: 'scm-plan-admin/api/v1/outService/dateLabels',
                        method: 'get',
                        params: {
                            "startDate": this.getBeginOflastWeek()
                        }
                    }).then(result => {
                        this.festivals = result.data.data
                        this.$nextTick(function () {
                            this.initEcharts();
                            this.initFestivals();
                        });
                    })
                },
                getUnit() {
                    this.$http({
                        url: "scm-plan-admin/api/v1/outService/listUnitType",
                        method: 'GET'
                    }).then(result => {
                        const data = result.data;
                        if (data && data.code === '0') {
                            data.data.forEach(e => {
                                let obj = {}
                                obj.unitType = e.unitType
                                obj.unitName = e.unitName
                                this.unitOption.push(obj);
                            })

                        }
                    })
                },
                lazyLoad3(node, resolve) {
                    if (node.level === 0) {
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/queryByLevel?level=1',
                            method: 'GET'
                        }).then(result => {
                            const nodes = result.data.data;
                            resolve(nodes);
                        })
                    } else {
                        let parentCode = node.value
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/parentChannel?parentChannel=' + parentCode,
                            method: 'GET'
                        }).then(result => {
                            const nodes = result.data.data;
                            if (nodes) {
                                nodes.forEach(e => e.level = 2)
                            }
                            resolve(nodes);
                        })
                    }
                },
                lazyLoad2(node, resolve) {
                    if (node.level === 0) {
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/searchAreaByLevels',
                            method: 'POST',
                            data: [1]
                        }).then(result => {
                            const nodes = result.data.data.list;
                            resolve(nodes);
                        })
                    } else {
                        let parentCode = node.value
                        let storeParamDTO = {};
                        storeParamDTO.districtCode = parentCode;
                        //下拉选项框只显示到区域的级别，不显示到办事处  区域的level默认是3
                        if (3 === node.data.level) {
                            this.$http({
                                url: 'scm-plan-admin/api/v1/outService/listStore?pageNum=1&pageSize=9999',
                                method: 'POST',
                                data: JSON.stringify(storeParamDTO)
                            }).then(result => {
                                resolve(result.data.data)
                            })
                        } else {
                            this.$http({
                                url: 'scm-plan-admin/api/v1/outService/searchByParentCode?parentCode=' + parentCode,
                                method: 'GET'
                            }).then(result => {
                                const nodes = result.data.data;
                                resolve(nodes);
                            })
                        }
                    }
                },
                lazyLoad1(node, resolve) {
                    if (node.level === 0) {
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/getCategoryListByLevel?level=2',
                            method: 'POST'
                        }).then(result => {
                            const nodes = result.data.data;
                            resolve(nodes);
                        })
                    } else {
                        let stringList = [];
                        stringList.push(node.value);
                        this.$http({
                            url: 'scm-plan-admin/api/v1/outService/categoryListByCategoryCodes',
                            method: 'POST',
                            data: stringList
                        }).then(result => {
                            node.check = true;
                            const nodes = (result.data.data)[0].categoryDTOList;
                            const id = (result.data.data)[0].id;
                            if (nodes.length > 0) {
                                resolve(nodes);
                            } else {
                                this.$http({
                                    url: "scm-plan-admin/api/v1/outService/skuListByCategoryId/" + id + "/1/9999",
                                    method: 'GET'
                                }).then(result => {
                                    const node = result.data.data;
                                    resolve(node)
                                })
                            }
                        })
                    }

                },

                getDataListIndex() {
                    this.pageIndex++
                    this.getDataList()
                },
                debounce(fn, wait) {
                    var timer = null;
                    return function () {
                        if (timer !== null) {
                            clearTimeout(timer);
                        }
                        timer = setTimeout(fn, wait);
                    }
                },
                // formatPeriod (datePeriod) {
                //     let dateArray = datePeriod.split('-');
                //     if(dateArray.length === 2) {
                //         let startDate = dateArray[0].substr(5)
                //         let endDate = dateArray[1].substr(5)
                //         return `${startDate}-${endDate}`;
                //     }else {
                //         return dateArray[0].substr(5)
                //     }
                // },
                getDataList() {
                    this.dataListLoading = true;
                    let _this = this
                    this.lastConfirmedQtyList = []
                    this.tableShow = false
                    this.dataForm.pageSize = this.pageSize;
                    this.dataForm.pageNum = this.pageIndex;
                    this.$http({
                        url: "/scm-plan-admin/api/v1/salesPlanOther/listWeek",
                        method: 'post',
                        data: this.dataForm
                    }).then(result => {
                        const data = result.data;
                        if (data && data.code === '0') {
                            const result = data.data
                            if (result && result.dateList) {
                                this.weekDate = result.dateList;
                            }
                            let list;
                            if (result && result.infoList) {
                                list = result.infoList;
                            }
                            if (!list) {
                                this.dataList = [];
                                this.totalCount = 0;
                            } else {
                                this.handerDataList(list);
                                this.rowMergeArrs = this.rowMergeHandle(this.needMergeArr, this.dataList); // 处理合并数据
                                this.pageIndex = data.data.pageNum
                                if (data.data.hasNextPage) {
                                    let tmpTotalCount = (data.data.pageNum + 1) * this.pageSize
                                    if(this.totalCount < tmpTotalCount){
                                        this.totalCount = tmpTotalCount
                                    }
                                }
                                //计算十四周日期
                                this.initWeekDates(this.dataForm.startTime)
                            }
                        } else {
                            this.$message.error(result.data.msg);
                            this.dataList = [];
                            this.totalPage = 0;
                        }
                        this.dataListLoading = false;
                        this.$nextTick(e => {
                            _this.tableShow = true
                        })
                    }).catch(() => {
                        this.dataListLoading = false;
                    })
                    /*const data = result.data;
                        if (data && data.code === '0') {
                            this.weekDate = data.data.dateList;
                            let list = data.data.infoList;
                            if (list == null) {
                                this.dataList = [];
                                this.totalCount = 0;
                            } else {
                                /!*this.otherTypeLists = []
                                this.otherImpTypeLists = []
                                list[0].otherTypeList.forEach(e => {
                                    let obj = {}
                                    obj.type = e.type
                                    obj.typeName = e.typeName
                                    this.otherTypeLists.push(obj);
                                })
                                if (list[0].otherImpTypeList.length > 0) {
                                    list[0].otherImpTypeList.forEach(e => {
                                        let obj = {}
                                        obj.type = e.type
                                        obj.typeName = e.typeName
                                        this.otherImpTypeLists.push(obj);
                                    })
                                }*!/
                                this.handerDataList(list);
                                this.rowMergeArrs = this.rowMergeHandle(this.needMergeArr, this.dataList); // 处理合并数据
                                this.totalCount = data.data.total;
                            }
                        } else {
                            this.$message.error(result.data.msg);
                            this.dataList = [];
                            this.totalPage = 0;
                        }
                        this.dataListLoading = false;
                        this.$nextTick(e => {
                            _this.tableShow = true
                        })*/
                },
                initWeekDates(startTime) {
                    let tmpDateList = []
                    this.tmpStartDateList = []
                    let date = new Date(Date.parse(startTime.replace(/-/g, "/")))
                    tmpDateList.push(date)
                    let tmp = date.valueOf();
                    let tDate;
                    for (let i = 0; i < 13; i++) {
                        tmp = tmp + 7 * 24 * 60 * 60 * 1000
                        tDate = new Date(tmp)
                        tmpDateList.push(tDate)
                    }
                    //将日期转换成yyyy-mm-dd格式
                    let y
                    let m
                    let d
                    for (let i = 0; i < 14; i++) {
                        y = tmpDateList[i].getFullYear();
                        m = tmpDateList[i].getMonth() + 1;
                        d = tmpDateList[i].getDate();
                        this.tmpStartDateList[i] = y + '-' + m + '-' + d;
                    }
                }
                ,
                //保存确认量
                confirmNum() {

                    /*if (this.multipleSelection.length == 0) {
                        this.$message({
                            message: '请勾选可以修改的数据',
                            type: 'info'
                        });
                        return
                    }
                    for (let i = 0; i < this.multipleSelection.length; i++) {
                        for (let j = 0; j < this.multipleSelection[i].confirmedQtys.length; j++) {
                            if (this.multipleSelection[i].confirmedQtys[j] === '') {
                                this.$message({
                                    message: '确认量不能为空并且不能有特殊字符',
                                    type: 'info'
                                });
                                return
                            }
                        }

                    }

                    let tag = []
                    for (let i = 0; i < this.multipleSelection.length; i++) {
                        for (let j = 0; j < this.multipleSelection[i].confirmedQtys.length; j++) {
                            if (this.multipleSelection[i].confirmedQtys[j] != this.lastConfirmedQtyList[this.multipleSelection[i].flag].confirmedQtys[j]) {
                                tag.push({
                                    id: this.multipleSelection[i].ids[j],
                                    confirmQtys: this.multipleSelection[i].confirmedQtys[j]

                                })
                            }
                        }
                    }
                    if (tag.length == 0) {
                        this.$message({
                            message: '请修改后再点击确认',
                            type: 'info'
                        });
                        return;
                    }*/

                    let set = []
                    let data = this.updateFrom;
                    let ifTrue = false;
                    if (this.dialogVisible1) {
                        if (this.$refs.tablemax.selection && this.$refs.tablemax.selection.length) {
                            ifTrue = true;
                        }
                    } else {
                        if (this.$refs.table.selection && this.$refs.table.selection.length) {
                            ifTrue = true;
                        }
                    }
                    if (ifTrue) {
                        data.forEach((e, i) => {
                            this.weekDate.forEach((a, j) => {
                                if (e.confirmedQtys[j] && e.confirmedQtys[j] !== this.lastConfirmedQtyList[i].confirmedQtys[j]) {
                                    let formData = {};
                                    let dateArr = a.split("-");
                                    let nowDate = new Date();
                                    let y = nowDate.getFullYear();
                                    let startDate = dateArr[0].split(".");
                                    let endDate = dateArr[1].split(".");
                                    formData.planStartDate = y + "-" + startDate[0] + "-" + startDate[1];
                                    formData.planEndDate = y + "-" + endDate[0] + "-" + endDate[1];
                                    formData.channelCode = e.channelCode;
                                    formData.areaCode = e.areaCode;
                                    formData.area = e.area;
                                    formData.skuCode = e.skuCode;
                                    formData.type = e.typeStu[0];
                                    formData.confirmedQty = e.confirmedQtys[j];
                                    set.push(formData);
                                }
                            })
                        })
                    } else {
                        this.$message({
                            message: '未选择数据或未修改数据',
                            type: 'error'
                        })
                        this.dataListLoading = false;
                        return false
                    }
                    if (set.length == 0) {
                        this.$message({
                            message: '未选择数据或未修改数据',
                            type: 'error'
                        })
                        this.dataListLoading = false;
                        return false
                    }
                    const loading = this.$loading({
                        lock: true,
                        text: '正在保存，请稍后···   ',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    this.$http({
                        url: 'scm-plan-admin/api/v1/salesPlanOther/confirm?unitType=' + this.dataForm.unitType,
                        method: 'put',
                        data: set
                    }).then(result => {
                        const data = result.data;
                        if (data && data.code === '0') {
                            this.multipleSelection = [];
                            this.$message({
                                message: '保存成功',
                                type: 'success'
                            })
                            this.getDataList();
                            this.initEcharts();
                        } else {
                            this.$message.error(data.msg);
                        }
                        loading.close();
                    }).catch(() => {
                        loading.close();
                        this.$message.error("系统异常，请联系管理员");
                    })
                },

                selectChange(selection) {
                    this.updateFrom = [];
                    if (selection && selection.length) {
                        selection.forEach(e => {
                            this.dataList.forEach(a => {
                                if (e.flag === a.flag && a.planConfirmLabel === '确认量') {
                                    this.updateFrom.push(a);
                                }
                            })
                        })
                    } else {
                        this.updateFrom = [];
                    }
                },
                selectAllChange(selection) {
                    this.updateFrom = [];
                    if (selection && selection.length) {
                        selection.forEach((e, idx) => {
                            if (e.flag === this.dataList[idx].flag && this.dataList[idx].planConfirmLabel === '确认量') {
                                this.updateFrom.push(this.dataList[idx]);
                            }
                        })
                    } else {
                        this.updateFrom = [];
                    }
                },
                // 勾选框改变状态
                /*handleSelectionChange(selection) {
                    this.updateFrom = [];
                    if (selection && selection.length) {
                        selection.forEach(e => {
                            this.dataList.forEach(a => {
                                if (e.index === a.index && a.confirmedQtys === this.labels[4]) {
                                    this.updateFrom.push(a);
                                }
                            })
                        })
                    } else {
                        this.updateFrom = [];
                    }

                    let arr = []
                    let newArr = []
                    //判断全选
                    if (checkArrays.length == this.dataList.length) {
                        for (let i = 0; i < checkArrays.length; i++) {
                            if (checkArrays[i].planConfirmLabel == '确认量') {
                                arr.push(checkArrays[i]);
                            }
                        }
                    } else {
                        if (checkArrays && checkArrays.length > 0) {
                            let index
                            //没有高级搜索选择指标
                            if (this.dataForm.quota1.length == 0) {
                                //导入人权限只有6个指标
                                if (this.levels == 2) {
                                    index = 7
                                    this.groupArr(checkArrays, 'ids').map(e => {
                                        if (e['list'].length == 1 || e['list'].length == index) {
                                            newArr.push(e['list'])
                                        }
                                    })

                                } else {
                                    index = 6
                                    this.groupArr(checkArrays, 'ids').map(e => {
                                        if (e['list'].length == 1 || e['list'].length == index) {
                                            newArr.push(e['list'])
                                        }
                                    })
                                }
                                for (let j = 0; j < newArr.length; j++) {
                                    for (let i = newArr[j][0].index; i < newArr[j][0].index + index; i++) {
                                        if (this.dataList[i].planConfirmLabel == '确认量') {
                                            arr.push(this.dataList[i]);

                                        }

                                    }
                                }
                            } else {
                                index = this.dataForm.quota1.length
                                this.groupArr(checkArrays, 'ids').map(e => {
                                    if (e['list'].length == 1 || e['list'].length == index) {
                                        newArr.push(e['list'])
                                    }
                                })
                                for (let j = 0; j < newArr.length; j++) {
                                    for (let i = newArr[j][0].index; i < newArr[j][0].index + index; i++) {
                                        if (this.dataList[i].planConfirmLabel == '确认量') {
                                            arr.push(this.dataList[i]);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    this.multipleSelection = arr;
                    console.log(this.multipleSelection)
                },*/


                groupArr(list, field) {
                    var fieldList = [], att = [];
                    list.map((e) => {
                        fieldList.push(e[field])
                    })
                    //数组去重
                    fieldList = fieldList.filter((e, i, self) => {
                        return self.indexOf(e) == i
                    })
                    for (var j = 0; j < fieldList.length; j++) {
                        //过滤出匹配到的数据
                        var arr = list.filter((e) => {
                            return e.ids == fieldList[j];
                        })
                        att.push({
                            ids: arr[0].ids,
                            list: arr
                        })
                    }
                    return att;
                },

                rowMergeHandle(arr, data) {
                    if (!Array.isArray(arr) && !arr.length) return false;
                    if (!Array.isArray(data) && !data.length) return false;
                    let needMerge = {};
                    arr.forEach(i => {
                        needMerge[i] = {
                            rowArr: [],
                            rowMergeNum: 0
                        };
                        data.forEach((item, index) => {
                            if (index === 0) {
                                needMerge[i].rowArr.push(1);
                                needMerge[i].rowMergeNum = 0;
                            } else {
                                if (item[i] === data[index - 1][i]) {
                                    needMerge[i].rowArr[needMerge[i].rowMergeNum] += 1;
                                    needMerge[i].rowArr.push(0);
                                } else {
                                    needMerge[i].rowArr.push(1);
                                    needMerge[i].rowMergeNum = index;
                                }
                            }
                        });
                    });
                    return needMerge;
                },

                mergeAction(val, rowIndex, colData) {
                    let _row = this.rowMergeArrs[val].rowArr[rowIndex];
                    let _col = _row > 0 ? 1 : 0;
                    return [_row, _col];
                },
                arraySpanMethod({row, column, rowIndex, columnIndex}) {
                    // 没办法循环判断具体是那一列 所以就只好写了多个if
                    /*if (column.property === 'channel') return this.mergeAction('area', rowIndex, column);
                    if (column.property === 'area') return this.mergeAction('category', rowIndex, column);
                    if (column.property === 'category') return this.mergeAction('skuName', rowIndex, column);
                    if (columnIndex === 0) return this.mergeAction('skuName', rowIndex, column);*/
                    if (columnIndex === 0 || column.property === 'channel' || column.property === 'type' || column.property === 'store' || column.property === 'area' || column.property === 'latestArrivalDate' || column.property === 'category' || column.property === 'skuName') {
                        if (this.isContain(this.dataForm.quota1, 0) && rowIndex % this.targetOption.length === 0) {
                            return {
                                rowspan: this.targetOption.length,
                                colspan: 1
                            }
                        } else if (this.isContain(this.dataForm.quota1, 0) && rowIndex % this.targetOption.length !== 0) {
                            return {
                                rowspan: 0,
                                colspan: 0
                            }
                        }
                        if (!this.isContain(this.dataForm.quota1, 0) && rowIndex % this.dataForm.quota1.length === 0) {
                            return {
                                rowspan: this.dataForm.quota1.length,
                                colspan: 1
                            }
                        } else if (!this.isContain(this.dataForm.quota1, 0) && rowIndex % this.dataForm.quota1.length !== 0) {
                            return {
                                rowspan: 0,
                                colspan: 0
                            }
                        }
                    }
                },
                isContain(list, item) {
                    if (list.length === 0) {
                        return true
                    }
                    let e = list.find(e => {
                        return e === item
                    })
                    if (e !== undefined) {
                        return true
                    } else {
                        return false
                    }
                },
                handerDataList(dataList) {
                    let newDataList = [];
                    let _this = this
                    let ind = 0
                    dataList.forEach((item, index, array) => {
                        let isInput = false
                        let statusStu = 2
                        let typeStu = 18
                        if (item.typeList) {
                            statusStu = item.statusList
                            typeStu = item.typeList
                        }
                        let planProportionss = []
                        item.planProportions.forEach(item => {
                            let it = item != 0 ? (item * 100).toFixed(3) + "%" : "-"
                            planProportionss.push(it)
                        })


                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 1)) {
                            newDataList.push({
                                ids: item.businessNo,
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                store: item.store,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                areaCode: item.areaCode,
                                category: item.category,
                                type: item.type,
                                planConfirmLabel: item.lastPlanQtyLabel, // 上次计划量名称
                                confirmedQtys: item.lastPlanQtys,            // 上次计划量集合
                                flag: index,
                                statusStu: statusStu,
                                typeStu: typeStu,
                                isInput: isInput,
                                latestArrivalDate: item.latestArrivalDate,
                                index: ind++,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 2)) {
                            newDataList.push({
                                ids: item.businessNo,
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                store: item.store,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                areaCode: item.areaCode,
                                category: item.category,
                                type: item.type,
                                planConfirmLabel: item.lastConfirmedQtyLabel, // 上次确认量名称
                                confirmedQtys: item.lastConfirmedQtys,            // 上次确认量集合
                                flag: index,
                                statusStu: statusStu,
                                typeStu: typeStu,
                                isInput: isInput,
                                latestArrivalDate: item.latestArrivalDate,
                                index: ind++,
                            });
                        }
                        if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 3)) {
                            newDataList.push({
                                ids: item.businessNo,
                                channel: item.channel,
                                channelCode: item.channelCode,
                                subChannelCode: item.subChannelCode,
                                provinceCode: item.provinceCode,
                                cityCode: item.cityCode,
                                countyCode: item.countyCode,
                                store: item.store,
                                priCategoryCode: item.priCategoryCode,
                                secCategoryCode: item.secCategoryCode,
                                terCategoryCode: item.terCategoryCode,
                                skuName: item.skuName,
                                skuCode: item.skuCode,
                                area: item.area,
                                areaCode: item.areaCode,
                                category: item.category,
                                type: item.type,
                                planConfirmLabel: item.planQtyLabel, // 计划量名称
                                confirmedQtys: item.planQtys,            // 计划量集合
                                flag: index,
                                statusStu: statusStu,
                                typeStu: typeStu,
                                isInput: isInput,
                                latestArrivalDate: item.latestArrivalDate,
                                index: ind++,
                            });
                        }
                        //全渠道负责人有下级确认量
                        if (this.levels == 2) {
                            if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 4)) {
                                newDataList.push({
                                    ids: item.businessNo,
                                    channel: item.channel,
                                    channelCode: item.channelCode,
                                    subChannelCode: item.subChannelCode,
                                    provinceCode: item.provinceCode,
                                    cityCode: item.cityCode,
                                    countyCode: item.countyCode,
                                    store: item.store,
                                    priCategoryCode: item.priCategoryCode,
                                    secCategoryCode: item.secCategoryCode,
                                    terCategoryCode: item.terCategoryCode,
                                    skuName: item.skuName,
                                    skuCode: item.skuCode,
                                    area: item.area,
                                    areaCode: item.areaCode,
                                    category: item.category,
                                    type: item.type,
                                    planConfirmLabel: item.subordinateConfirmedQtyLabel, // 下级确认量名称
                                    confirmedQtys: item.subordinateConfirmedQtys,            // 下级确认量集合
                                    flag: index,
                                    statusStu: statusStu,
                                    typeStu: typeStu,
                                    isInput: isInput,
                                    latestArrivalDate: item.latestArrivalDate,
                                    index: ind++
                                });
                            }
                            if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 5)) {
                                newDataList.push({
                                    ids: item.businessNo,
                                    channel: item.channel,
                                    channelCode: item.channelCode,
                                    subChannelCode: item.subChannelCode,
                                    provinceCode: item.provinceCode,
                                    cityCode: item.cityCode,
                                    countyCode: item.countyCode,
                                    store: item.store,
                                    priCategoryCode: item.priCategoryCode,
                                    secCategoryCode: item.secCategoryCode,
                                    terCategoryCode: item.terCategoryCode,
                                    skuName: item.skuName,
                                    skuCode: item.skuCode,
                                    area: item.area,
                                    areaCode: item.areaCode,
                                    category: item.category,
                                    type: item.type,
                                    planConfirmLabel: item.confirmedQtyLabel, // 确认量名称
                                    confirmedQtys: item.confirmedQtys,            // 确认量集合
                                    planQtys: item.planQtys,
                                    flag: index,
                                    index: ind++,
                                    statusStu: statusStu,
                                    typeStu: typeStu,
                                    isInput: true,
                                    latestArrivalDate: item.latestArrivalDate,
                                    types: 1
                                });
                                let confirmedQtyList = [];
                                confirmedQtyList.push(...item.confirmedQtys);
                                this.lastConfirmedQtyList.push({confirmedQtys: confirmedQtyList})
                            }
                            if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 6)) {
                                newDataList.push({
                                    ids: item.businessNo,
                                    channel: item.channel,
                                    channelCode: item.channelCode,
                                    subChannelCode: item.subChannelCode,
                                    provinceCode: item.provinceCode,
                                    cityCode: item.cityCode,
                                    countyCode: item.countyCode,
                                    store: item.store,
                                    priCategoryCode: item.priCategoryCode,
                                    secCategoryCode: item.secCategoryCode,
                                    terCategoryCode: item.terCategoryCode,
                                    skuName: item.skuName,
                                    skuCode: item.skuCode,
                                    area: item.area,
                                    areaCode: item.areaCode,
                                    category: item.category,
                                    type: item.type,
                                    planConfirmLabel: item.planDifferenceLabel, // 计划与确认差值名称
                                    confirmedQtys: item.planDifferences,            // 计划与确认差值集合
                                    flag: index,
                                    statusStu: statusStu,
                                    typeStu: typeStu,
                                    isInput: isInput,
                                    latestArrivalDate: item.latestArrivalDate,
                                    index: ind++,
                                });
                            }

                            if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 7)) {
                                newDataList.push({
                                    ids: item.businessNo,
                                    channel: item.channel,
                                    channelCode: item.channelCode,
                                    subChannelCode: item.subChannelCode,
                                    provinceCode: item.provinceCode,
                                    cityCode: item.cityCode,
                                    countyCode: item.countyCode,
                                    store: item.store,
                                    priCategoryCode: item.priCategoryCode,
                                    secCategoryCode: item.secCategoryCode,
                                    terCategoryCode: item.terCategoryCode,
                                    skuName: item.skuName,
                                    skuCode: item.skuCode,
                                    area: item.area,
                                    areaCode: item.areaCode,
                                    category: item.category,
                                    type: item.type,
                                    planConfirmLabel: item.planProportionLabel, // 计划与确认比例名称
                                    confirmedQtys: planProportionss,            // 计划与确认比例集合
                                    flag: index,
                                    statusStu: statusStu,
                                    typeStu: typeStu,
                                    isInput: isInput,
                                    latestArrivalDate: item.latestArrivalDate,
                                    index: ind++
                                });
                            }
                            if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 8)) {
                                newDataList.push({
                                    ids: item.businessNo,
                                    channel: item.channel,
                                    channelCode: item.channelCode,
                                    subChannelCode: item.subChannelCode,
                                    provinceCode: item.provinceCode,
                                    cityCode: item.cityCode,
                                    countyCode: item.countyCode,
                                    store: item.store,
                                    priCategoryCode: item.priCategoryCode,
                                    secCategoryCode: item.secCategoryCode,
                                    terCategoryCode: item.terCategoryCode,
                                    skuName: item.skuName,
                                    skuCode: item.skuCode,
                                    area: item.area,
                                    areaCode: item.areaCode,
                                    category: item.category,
                                    type: item.type,
                                    planConfirmLabel: item.actualSalesQtyLabel, // 实际销量名称
                                    confirmedQtys: item.actualSalesQty,            // 实际销量集合
                                    flag: index,
                                    statusStu: statusStu,
                                    typeStu: typeStu,
                                    isInput: isInput,
                                    latestArrivalDate: item.latestArrivalDate,
                                    index: ind++,
                                    types: 2
                                });
                            }

                        } else {
                            if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 4)) {
                                newDataList.push({
                                    ids: item.businessNo,
                                    channel: item.channel,
                                    channelCode: item.channelCode,
                                    subChannelCode: item.subChannelCode,
                                    provinceCode: item.provinceCode,
                                    cityCode: item.cityCode,
                                    countyCode: item.countyCode,
                                    store: item.store,
                                    priCategoryCode: item.priCategoryCode,
                                    secCategoryCode: item.secCategoryCode,
                                    terCategoryCode: item.terCategoryCode,
                                    skuName: item.skuName,
                                    skuCode: item.skuCode,
                                    area: item.area,
                                    areaCode: item.areaCode,
                                    category: item.category,
                                    type: item.type,
                                    planConfirmLabel: item.confirmedQtyLabel, // 确认量名称
                                    confirmedQtys: item.confirmedQtys,            // 确认量集合
                                    planQtys: item.planQtys,
                                    flag: index,
                                    index: ind++,
                                    statusStu: statusStu,
                                    typeStu: typeStu,
                                    isInput: true,
                                    latestArrivalDate: item.latestArrivalDate,
                                    types: 1
                                });
                                let confirmedQtyList = [];
                                confirmedQtyList.push(...item.confirmedQtys);
                                this.lastConfirmedQtyList.push({confirmedQtys: confirmedQtyList})
                            }
                            if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 5)) {
                                newDataList.push({
                                    ids: item.businessNo,
                                    channel: item.channel,
                                    channelCode: item.channelCode,
                                    subChannelCode: item.subChannelCode,
                                    provinceCode: item.provinceCode,
                                    cityCode: item.cityCode,
                                    countyCode: item.countyCode,
                                    store: item.store,
                                    priCategoryCode: item.priCategoryCode,
                                    secCategoryCode: item.secCategoryCode,
                                    terCategoryCode: item.terCategoryCode,
                                    skuName: item.skuName,
                                    skuCode: item.skuCode,
                                    area: item.area,
                                    areaCode: item.areaCode,
                                    category: item.category,
                                    type: item.type,
                                    planConfirmLabel: item.planDifferenceLabel, // 计划与确认差值名称
                                    confirmedQtys: item.planDifferences,            // 计划与确认差值集合
                                    flag: index,
                                    statusStu: statusStu,
                                    typeStu: typeStu,
                                    isInput: isInput,
                                    latestArrivalDate: item.latestArrivalDate,
                                    index: ind++,
                                });
                            }

                            if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 6)) {
                                newDataList.push({
                                    ids: item.businessNo,
                                    channel: item.channel,
                                    channelCode: item.channelCode,
                                    subChannelCode: item.subChannelCode,
                                    provinceCode: item.provinceCode,
                                    cityCode: item.cityCode,
                                    countyCode: item.countyCode,
                                    store: item.store,
                                    priCategoryCode: item.priCategoryCode,
                                    secCategoryCode: item.secCategoryCode,
                                    terCategoryCode: item.terCategoryCode,
                                    skuName: item.skuName,
                                    skuCode: item.skuCode,
                                    area: item.area,
                                    areaCode: item.areaCode,
                                    category: item.category,
                                    type: item.type,
                                    planConfirmLabel: item.planProportionLabel, // 计划与确认比例名称
                                    confirmedQtys: planProportionss,            // 计划与确认比例集合
                                    flag: index,
                                    statusStu: statusStu,
                                    typeStu: typeStu,
                                    isInput: isInput,
                                    latestArrivalDate: item.latestArrivalDate,
                                    index: ind++
                                });
                            }
                            if (_this.isContain(_this.dataForm.quota1, 0) || _this.isContain(_this.dataForm.quota1, 7)) {
                                newDataList.push({
                                    ids: item.businessNo,
                                    channel: item.channel,
                                    channelCode: item.channelCode,
                                    subChannelCode: item.subChannelCode,
                                    provinceCode: item.provinceCode,
                                    cityCode: item.cityCode,
                                    countyCode: item.countyCode,
                                    store: item.store,
                                    priCategoryCode: item.priCategoryCode,
                                    secCategoryCode: item.secCategoryCode,
                                    terCategoryCode: item.terCategoryCode,
                                    skuName: item.skuName,
                                    skuCode: item.skuCode,
                                    area: item.area,
                                    areaCode: item.areaCode,
                                    category: item.category,
                                    type: item.type,
                                    planConfirmLabel: item.actualSalesQtyLabel, // 实际销量名称
                                    confirmedQtys: item.actualSalesQty,           // 实际销量集合
                                    flag: index,
                                    statusStu: statusStu,
                                    typeStu: typeStu,
                                    isInput: isInput,
                                    latestArrivalDate: item.latestArrivalDate,
                                    index: ind++,
                                    types: 2
                                });
                            }
                        }
                    });
                    this.dataList = newDataList
                },
                initFestivals() {
                    this.$refs.timeLine.vueComponent.festivalList = this.festivals
                    this.$refs.timeLine.vueComponent.initDate()
                },
                showDialog() {
                    this.dialogVisible = true
                    this.$nextTick(function () {
                        this.initEcharts();
                    });
                },
                initEcharts(boo) {
                    this.echartsLoading = true;
                    // 基于准备好的dom，初始化echarts实例
                    let _this = this
                    if (boo) {
                        _this.dataForm.startTime = boo[0];
                        _this.dataForm.endTime = boo[1];
                    }
                    this.$http({
                        url: '/scm-plan-admin/api/v1/salesPlanOther/eChartsData',
                        method: 'post',
                        data: _this.dataForm
                    }).then(result => {
                        if (result.data.code === '0') {
                            _this.lastPlanQtys = []
                            _this.lastConfirmedQtys = []
                            _this.planQtys = []
                            _this.confirmedQtys = []
                            _this.planDifferences = []
                            _this.planProportions = []
                            _this.actualSalesQtys = []
                            if (this.levels == 2) {
                                _this.subordinateConfirmedQtys = []
                            }
                            if (result.data.data) {
                                _this.dateList = result.data.data.dateList
                                if (result.data.data.infoList) {
                                    result.data.data.infoList.forEach(e => {
                                        let planProportionss = [];
                                        _this.lastPlanQtys = e.lastPlanQtys
                                        _this.lastConfirmedQtys = e.lastConfirmedQtys
                                        _this.planQtys = e.planQtys
                                        if (this.levels == 2) {
                                            _this.subordinateConfirmedQtys = e.subordinateConfirmedQtys
                                        }
                                        _this.confirmedQtys = e.confirmedQtys
                                        _this.planDifferences = e.planDifferences
                                        if (e.planProportions) {
                                            e.planProportions.forEach(e => {
                                                planProportionss.push(e);
                                            })
                                        }
                                        _this.planProportions = this.acFormat(planProportionss)
                                        _this.actualSalesQtys = e.actualSalesQty
                                    })
                                }
                            }

                            _this.initOpentionEcharts()
                        } else {
                            _this.$message.error(result.data.msg);
                            this.echartsLoading = false;
                        }
                    }).then(e => {
                    })

                },

                initOpentionEcharts() {
                    let _this = this
                    let ec = null;
                    if (echarts != undefined) {
                        ec = echarts;
                    } else {
                        ec = window.echarts;
                    }
                    var myChart = ec.init(document.getElementById('echarts'));
                    let arr = {}
                    let serArr = []
                    let serArr1 = [
                        {
                            name: '上次计划量',
                            type: 'bar',
                            data: _this.lastPlanQtys
                        },
                        {
                            name: '上次确认量',
                            type: 'bar',
                            data: _this.lastConfirmedQtys
                        },
                        {
                            name: '计划量',
                            type: 'bar',
                            data: _this.planQtys
                        },
                        {
                            name: '确认量',
                            type: 'bar',
                            data: _this.confirmedQtys
                        },
                        {
                            name: '计划与确认差值',
                            type: 'bar',
                            data: _this.planDifferences
                        },
                        {
                            name: '计划与确认比例',
                            yAxisIndex: 1,
                            type: 'line',
                            data: _this.planProportions
                        },
                        {
                            name: '实际销量',
                            type: 'bar',
                            data: _this.actualSalesQtys
                        }
                    ]

                    let serArr2 = [
                        {
                            name: '上次计划量',
                            type: 'bar',
                            data: _this.lastPlanQtys
                        },
                        {
                            name: '上次确认量',
                            type: 'bar',
                            data: _this.lastConfirmedQtys
                        },
                        {
                            name: '计划量',
                            type: 'bar',
                            data: _this.planQtys
                        },
                        {
                            name: '确认量',
                            type: 'bar',
                            data: _this.confirmedQtys
                        }, {
                            name: '下级确认量',
                            type: 'bar',
                            data: _this.subordinateConfirmedQtys
                        },
                        {
                            name: '计划与确认差值',
                            type: 'bar',
                            data: _this.planDifferences
                        },
                        {
                            name: '计划与确认比例',
                            yAxisIndex: 1,
                            type: 'line',
                            data: _this.planProportions
                        },
                        {
                            name: '实际销量',
                            type: 'bar',
                            data: _this.actualSalesQtys
                        }
                    ]
                    if (this.levels == 2) {
                        serArr = serArr2
                    } else {
                        serArr = serArr1
                    }

                    let arr2 = []
                    serArr.forEach(e => {
                        let obj = _this.values.find(e1 => {
                            return e1 === e.name
                        })
                        if (obj) {
                            arr2.push(e)
                        }
                    })
                    let option = {
                        color: ['#4BA2FD', '#5AD8A6', '#6DC8EC', '#945FB9'],
                        title: {
                            text: ''
                        },
                        dataZoom: [
                            {
                                type: 'slider',//有单独的滑动条，用户在滑动条上进行缩放或漫游。inside是直接可以是在内部拖动显示
                                show: true,//是否显示 组件。如果设置为 false，不会显示，但是数据过滤的功能还存在。
                                start: 0,//数据窗口范围的起始百分比0-100
                                end: 100,//数据窗口范围的结束百分比0-100
                                bottom: -10 //距离底部的距离
                            },
                            //2.在内部可以横向拖动
                            {
                                type: 'inside',// 内置于坐标系中
                                start: 0,
                                end: 100
                            }
                        ],
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'cross',
                                crossStyle: {
                                    color: '#999'
                                }
                            }
                        },
                        legend: {
                            type: 'scroll',
                            orient: 'horizontal',
                            data: _this.values,
                            selected: arr
                        },
                        grid: {
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            containLabel: true
                        },
                        xAxis: {
                            type: 'category',
                            data: _this.dateList,
                            axisPointer: {
                                type: 'shadow'
                            }
                        },
                        yAxis: [
                            {
                                type: 'value',
                                name: '量',
                                axisLabel: {
                                    formatter: '{value}'
                                }
                            },
                            {
                                type: 'value',
                                name: '百分比',
                                axisLabel: {
                                    formatter: '{value} %'
                                },
                                splitLine: {     //去掉网格线
                                    show: false
                                }
                            }
                        ],
                        series: arr2
                    };
                    this.echartsLoading = false;
                    myChart.setOption(option, true);
                },

                acFormat(val) {
                    let acFormatQty = []
                    val.forEach(e => {
                        let qty = e
                        let qtys
                        if (qty === 0) {
                            qtys = (qty * 1000).toFixed(3)
                        } else {
                            qtys = (qty * 100).toFixed(3)
                        }
                        acFormatQty.push(qtys)
                    })
                    return acFormatQty
                },
                offsetFun(val) {
                    let offSetNum = val.target.vueComponent.offSetNum
                    let obj = {
                        startTime: '',
                        endTime: ''
                    }
                    if (offSetNum === 16) {
                        obj.startTime = this.dateFormat('YYYY-mm-dd HH:MM:SS', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum - 1].date),
                            obj.endTime = this.dateFormat('YYYY-mm-dd HH:MM:SS', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum].date1)
                    } else {
                        obj.startTime = this.dateFormat('YYYY-mm-dd HH:MM:SS', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum - 1].date)
                        obj.endTime = this.dateFormat('YYYY-mm-dd HH:MM:SS', val.target.vueComponent.dateList[val.target.vueComponent.offSetNum + 1].date)
                    }
                    this.dataForm.startTime = obj.startTime
                    this.dataList = []
                    this.pageIndex = 1
                    this.totalCount = 0
                    this.getDataList()
                },
                changePicker(val) {
                    this.initEcharts(val)
                    this.exportTime = val
                },
                //搜索
                searchList() {
                    let _this = this
                    this.dataList = []
                    //this.pageIndex = 1
                    this.dataForm.quota1 = this.dataForm.quota11
                    //渠道
                    this.dataForm.channelCodeList = []
                    //区域
                    this.dataForm.areaCodeList = []
                    //品类
                    this.dataForm.categoryCodeList = []
                    //计划类型
                    this.dataForm.typeList = []
                    //商品分层
                    this.dataForm.layeredCodeList = []
                    let level;
                    let code;
                    debugger
                    if (this.dataForm.channelCodess) {
                        for (let i = 0; i < this.dataForm.channelCodess.length; i++) {
                            let j = 1;
                            this.dataForm.channelCodess[i].forEach(e => {
                                level = j
                                code = e
                                j++
                            })
                            this.dataForm.channelCodeList.push(code)
                        }
                    }
                    if (this.dataForm.areaCodes) {
                        for (let i = 0; i < this.dataForm.areaCodes.length; i++) {
                            let j = 1;
                            this.dataForm.areaCodes[i].forEach(e => {
                                level = j
                                code = e
                                j++
                            })
                            this.dataForm.areaCodeList.push(
                                {
                                    level: level,
                                    code: code
                                }
                            )
                        }
                    }

                    if (this.dataForm.categoryCodess) {
                        for (let i = 0; i < this.dataForm.categoryCodess.length; i++) {
                            let j = 2;
                            this.dataForm.categoryCodess[i].forEach(e => {
                                level = j
                                code = e
                                j++
                            })
                            this.dataForm.categoryCodeList.push(
                                {
                                    level: level,
                                    code: code
                                }
                            )
                        }
                    }
                    if (this.dataForm.layeredCodess) {
                        this.dataForm.layeredCodess.forEach(e => {
                            this.dataForm.layeredCodeList.push(e)

                        })
                    }
                    if (this.dataForm.typess) {
                        this.dataForm.typess.forEach(e => {
                            this.dataForm.typeList.push(e)

                        })
                    }
                    let skuCodeS = _this.dataForm.skuCodeS;
                    if (skuCodeS && skuCodeS.length) {
                        let skuCode = skuCodeS.split(/[(\r\n)\r\n]+/);
                        skuCode.forEach(e => {
                            _this.dataForm.categoryCodeList.push({
                                level: 5,
                                code: e
                            })
                        })
                    }
                    this.pageIndex = 1
                    this.totalCount = 0
                    this.getDataList()
                    this.initEcharts()
                    this.dialogVisible = false
                    this.dialogFormVisible = false
                },
                advancedSearch() {
                    this.dialogVisible = true
                },
                /*initData() {
                    this.tableData = []
                    this.tables = this.rowData[0]['dates']
                    for (let i = 0; i < 10; i++) {
                        this.rowData.push(this.rowData[0])
                    }
                    this.rowData.forEach(e => {
                        let channelCode = e['channelCode']
                        let gmvTarget = e.gmvTargets
                        gmvTarget.channelCode = channelCode
                        this.tableData.push(gmvTarget)
                        let gmvRealTarget = e.gmvRealTargets
                        gmvRealTarget.channelCode = channelCode
                        this.tableData.push(gmvTarget)
                        let a = e.a
                        a.channelCode = channelCode
                        this.tableData.push(a)
                        let b = e.b
                        b.channelCode = channelCode
                        this.tableData.push(b)
                    })
                },*/
                clearCondition() {
                    this.dataForm.skuCodeS = ''
                    this.dataForm.channelCodess = []
                    //this.dataForm.randType = []
                    this.dataForm.typess = []
                    this.dataForm.areaCodes = []
                    this.dataForm.categoryCodess = []
                    this.dataForm.layeredCodess = []
                    this.dataForm.quota11 = []
                    /*for (key in this.dataForm) {
                        this.dataForm[key] = ''
                    }*/
                },
                sizeChangeHandle(val) {
                    this.pageSize = val;
                    this.pageIndex = 1;
                    this.totalCount = 0
                    this.getDataList();
                },
                currentChangeHandle(val) {
                    this.pageIndex = val;
                    this.getDataList();
                },
                onClickCancelBtn() {
                    this.fileList = [];
                    this.activeStep = 1;
                    this.dialogVisible3 = false;
                    this.importErrInfo = '';
                },
                handleCommand(command) {
                    this.templateType = command;
                    this.dialogVisible3 = true;
                },
                //上传文件
                submitUpload() {
                    let that = this;
                    const loading = this.$loading({
                        lock: true,
                        text: '上传中···   ',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    const config = {headers: {'Content-Type': 'multipart/form-data'}}
                    let uploadData = new FormData()
                    uploadData.append("file", this.fileList[0].raw)
                    this.$http.post('scm-plan-admin/api/v1/salesPlanOther/importVerification?type=' + this.templateType, uploadData, config
                    ).then(function (res) {
                        const data = res.data;
                        if (data.data === 1) {
                            that.$message.success('上传成功')
                            that.activeStep = 3;
                            loading.close();
                            that.totalCount = 0
                            that.pageIndex = 1
                            that.getDataList();
                            that.initEcharts();
                        } else if (data.data === 0) {
                            that.$message.info('数据已导入')
                            that.importErrInfo = "数据导入中，请点击任务列表查看导入结果";
                            that.activeStep = 2;
                            loading.close();
                        } else {
                            that.$message.error('上传失败')
                            that.importErrInfo = data.msg;
                            that.activeStep = 2;
                            loading.close();
                        }
                    }).catch(e => {
                        that.$message.error('上传失败')
                        that.importErrInfo = '服务器异常'
                        that.activeStep = 2
                        loading.close();
                    });
                },
                //初始化上传接口参数
                handleChangeUpload(file) {
                    var FileExt = file.name.replace(/.+\./, "");
                    if (['xls', 'xlsx'].indexOf(FileExt.toLowerCase()) === -1) {
                        this.importErrInfo = '非excel文件';
                    }
                    this.fileList.push(file)
                    this.activeStep = 2;
                },
                //关闭上传框
                handleClose(done) {
                    this.fileList = [];
                    this.activeStep = 1;
                    this.dialogVisible3 = false;
                    this.importErrInfo = '';
                    done();
                },
                //模板下载
                downLodeTemplate() {
                    const loading = this.$loading({
                        lock: true,
                        text: '下载中···   ',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    this.$http({
                        url: 'scm-plan-admin/api/v1/salesPlanOther/downLoadTemplate/',
                        responseType: 'blob',
                        method: 'post',
                        params: {type: this.templateType,
                            date: ""}
                    }).then(result => {
                        let fileName;
                        if (this.templateType == 11) {
                            fileName = "销售计划(加盟)导入模板";
                        } else if (this.templateType == 12) {
                            fileName = "销售计划(APP)导入模板";
                        } else if (this.templateType == 13) {
                            fileName = "销售计划(经销中心)导入模板";
                        } else if (this.templateType == 14) {
                            fileName = "销售计划(云商)导入模板";
                        } else if (this.templateType == 15) {
                            fileName = "新开店计划导入模板";
                        } else if (this.templateType == 16) {
                            fileName = "新品铺货计划导入模板";
                        } else if (this.templateType == 17) {
                            fileName = "销售计划(直营)导入模板";
                        }
                        let blob = new Blob([result.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
                        if ('download' in document.createElement('a')) { // 非IE下载
                            const elink = document.createElement('a')
                            elink.download = fileName
                            elink.style.display = 'none'
                            elink.href = URL.createObjectURL(blob)
                            document.body.appendChild(elink)
                            elink.click()
                            URL.revokeObjectURL(elink.href) // 释放URL 对象
                            document.body.removeChild(elink)
                        } else { // IE10+下载
                            navigator.msSaveBlob(blob, fileName)
                        }
                        loading.close();
                    }).catch(function (e) {
                        loading.close();
                    })


                    /*this.$http({
                        url: 'scm-plan-admin/api/v1/salesPlanOther/downLoadTemplate/' + this.templateType,
                        method: 'get',
                    }).then(result => {
                        const data = result.data;
                        if (data && data.code === '0') {
                            //新开店模板需要每次去查品类套餐生成
                            if (data.data == 15) {
                                setTimeout(function () {
                                    window.location.href = 'http://' + window.location.host + '/scm-plan-admin/js/components/stencil/新开店计划.xlsx'
                                    //window.location.href = 'http://'+window.location.host+'/js/components/stencil/新开店计划.xlsx'
                                }, 7000)
                                setTimeout(function () {
                                    loading.close();
                                }, 7000)
                            } else if (data.data == 11) {
                                window.location.href = 'http://' + window.location.host + '/js/components/stencil/销售计划(加盟).xlsx'
                            } else if (data.data == 12) {
                                window.location.href = 'http://' + window.location.host + '/js/components/stencil/销售计划(APP).xlsx'
                            } else if (data.data == 13) {
                                window.location.href = 'http://' + window.location.host + '/js/components/stencil/销售计划(经销中心).xlsx'
                            } else if (data.data == 14) {
                                window.location.href = 'http://' + window.location.host + '/js/components/stencil/销售计划(云商).xlsx'
                            } else if (data.data == 16) {
                                window.location.href = 'http://' + window.location.host + '/js/components/stencil/新品铺货计划.xlsx'
                            }
                            loading.close();
                        } else {
                            loading.close();
                            this.$message.error("导出模板失败！");
                        }
                    }).catch(() => {
                        loading.close();
                        this.$message.error("导出模板失败！");
                    })*/
                },

                fullScreen() {
                    let _this = this
                    _this.dialogVisible1 = true
                    if (_this.$refs.table.selection && _this.$refs.table.selection.length) {
                        let selection = _this.$refs.table.selection
                        let rows = []
                        selection.forEach(item => {
                            rows.push(item)
                        })
                        //赋值全屏table
                        _this.$nextTick(function () {
                            this.$refs.tablemax.clearSelection();
                            if (rows) {
                                rows.forEach(row => {
                                    _this.$refs.tablemax.toggleRowSelection(row, true);
                                });
                            }
                        });
                    }
                },
                open(msg) {
                    this.$alert(msg, '提示', { confirmButtonText: '确定' });
                },
                //下载
                command(val) {
                    let filename = '其他渠道计划'
                    let _this = this
                    this.dataForm.pageSize = this.pageSize;
                    this.dataForm.pageNum = this.pageIndex;
                    if (_this.exportTime) {
                        _this.dataForm.startTime = _this.exportTime[0]
                        _this.dataForm.endTime = _this.exportTime[1]
                    }
                    let boo = false
                    if (val === 2) {
                        let set = new Set()
                        if (this.dialogVisible1) {
                            if (this.$refs.tablemax.selection && this.$refs.tablemax.selection.length > 0) {
                                this.$refs.tablemax.selection.forEach(e => {
                                    set.add(e.flag)
                                })
                            } else {
                                boo = true
                            }
                        } else {
                            if (this.$refs.table.selection && this.$refs.table.selection.length > 0) {
                                this.$refs.table.selection.forEach(e => {
                                    set.add(e.flag)
                                })
                            } else {
                                boo = true
                            }

                        }
                        this.dataForm.rowIndex = []
                        this.dataForm.rowIndex.push(...set)
                    }
                    if (boo) {
                        this.$message({
                            message: '请选择至少一条数据',
                            type: 'error'
                        })
                        return false
                    }
                    const loading = this.$loading({
                        lock: true,
                        text: '下载中···   ',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    this.$http({
                        url: '/scm-plan-admin/api/v1/salesPlanOther/export',
                        method: 'post',
                        data: this.dataForm,
                        params: {type: val}
                    }).then(result => {
                        loading.close();
                        this.open(result.data.data);
                        /*const fileName = "" + filename + ".xlsx"
                        let blob = new Blob([result.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
                        if ('download' in document.createElement('a')) { // 非IE下载
                            const elink = document.createElement('a')
                            elink.download = fileName
                            elink.style.display = 'none'
                            elink.href = URL.createObjectURL(blob)
                            document.body.appendChild(elink)
                            elink.click()
                            URL.revokeObjectURL(elink.href) // 释放URL 对象
                            document.body.removeChild(elink)
                        } else { // IE10+下载
                            navigator.msSaveBlob(blob, fileName)
                        }*/

                    }).catch(function (e) {
                        loading.close();
                    })
                },
                leaveFullScreen() {
                    let _this = this
                    _this.dialogVisible1 = false
                    if (_this.$refs.tablemax.selection && _this.$refs.tablemax.selection.length) {
                        let selection = _this.$refs.tablemax.selection
                        let rows = []
                        selection.forEach(item => {
                            rows.push(item)
                        })
                        //赋值全屏table
                        this.$refs.table.clearSelection();
                        if (rows) {
                            rows.forEach(row => {
                                _this.$refs.table.toggleRowSelection(row, true);
                            });
                        }
                    }
                },
                download(data) {
                    if (!data) {
                        return
                    }
                    let url = window.URL.createObjectURL(new Blob([data]))
                    let link = document.createElement('a')
                    link.style.display = 'none'
                    link.href = url
                    link.setAttribute('download', 'excel.xlsx')

                    document.body.appendChild(link)
                    link.click()
                }, labelChange(val) {
                    this.initOpentionEcharts()
                }, dateFormat(fmt, date) {

                    let ret;
                    const opt = {
                        "Y+": date.getFullYear().toString(),        // 年
                        "m+": (date.getMonth() + 1).toString(),     // 月
                        "d+": date.getDate().toString(),            // 日
                        "H+": date.getHours().toString(),           // 时
                        "M+": date.getMinutes().toString(),         // 分
                        "S+": date.getSeconds().toString()          // 秒
                        // 有其他格式化字符需求可以继续添加，必须转化成字符串
                    };
                    for (let k in opt) {
                        ret = new RegExp("(" + k + ")").exec(fmt);
                        if (ret) {
                            fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
                        }
                        ;
                    }
                    ;
                    return fmt;
                }, findStyle({row, column, rowIndex, columnIndex}) {
                    if (column.label && typeof parseInt(column.label.substr(0, 1)) === 'number' && !isNaN(column.label.substr(0, 1))) {
                        return "padding: 0;background: #4ba2fd;color: #ffffff"
                    } else {
                        return "padding: 0;background: #f8f8f8"
                    }
                },
                // 关闭窗口
                closeChooseGoodsDialog() {
                    this.chooseGoodsDialog = false
                },
                //查看日志
                choiceAllocationDetail() {
                    this.chooseGoodsDialog = true
                    this.$nextTick(() => {
                        this.$refs.scmPlanCommonChoosegoods.getDataList(4)
                    })
                },
                getBeginOflastWeek() {
                    let nowdate = new Date();
                    let oneweekdate = new Date(nowdate - 7 * 24 * 3600 * 1000);
                    let nowDayOfWeek = oneweekdate.getDay(); // 本周的第几天
                    let nowDay = oneweekdate.getDate(); // 当前日
                    let nowMonth = oneweekdate.getMonth(); // 当前月
                    let nowYear = oneweekdate.getFullYear(); // 当前年
                    let weekStartDate = new Date(nowYear, nowMonth, nowDay - (nowDayOfWeek == 0 ? 7 : nowDayOfWeek) + 1)
                    let y = weekStartDate.getFullYear();
                    // let m = String(weekStartDate.getMonth() + 1).length === 1 ? '0' + (weekStartDate.getMonth() + 1) : weekStartDate.getMonth() + 1;
                    // let d = String(weekStartDate.getDate()).length === 1 ? '0' + weekStartDate.getDate() : weekStartDate.getDate();
                    let m = weekStartDate.getMonth() + 1;
                    let d = weekStartDate.getDate();
                    let formatwdate = y + '-' + m + '-' + d;
                    return formatwdate;
                },
                /*点击单位触发事件*/
                commandUnit(val) {
                    this.defaultUnit = val.unitName
                    this.dataForm.unitType = val.unitType;
                    this.getDataList();
                    this.initEcharts();
                },indexContent(val){
                    switch(val) {
                        case '上次计划量':
                            return '上周录入计划量（渠道）'
                            break;
                        case '上次确认量':
                            return '上周录入确认量（渠道）'
                            break;
                        case '计划量':
                            return '本周录入计划量（渠道）'
                            break;
                        case '下级确认量':
                            return '单品-渠道下级确认量'
                            break;
                        case '确认量':
                            return '本周实际确认量（渠道）'
                            break;
                        case '计划与确认差值':
                            return '确认量（渠道）—计划量（渠道）'
                            break;
                        case '计划与确认比例':
                            return '确认量（渠道）—计划量（渠道）/确认量（渠道）'
                            break;
                        /*case '实际销量':
                            return '当前每周实际销售量'
                            break;*/
                        default:
                            return ''
                    }
                }

            },
            template: `
    <div>
                <el-card class="box-card">
                <el-dialog  :visible.sync="chooseGoodsDialog" title="任务列表"  width="80%" :modal="true">
            <span>
            <scmPlanCommonChoosegoods v-if="chooseGoodsDialog" ref="scmPlanCommonChoosegoods"  @closeChooseGoodsDialog="closeChooseGoodsDialog"></plan-common-choosegoods>
          </span>
        </el-dialog>
              <div slot="header" class="clearfix">
                <div style="text-align: right;margin: 5px">
                
                <span style="float: left;color: rgba(0,0,0,0.85);font-size: 16px;line-height:35px">时间范围</span>
                <el-button size="small" style="float: left;margin-left: 10px"  @click="fullScreen" >全屏</el-button>
                <el-button size="small"  icon="el-icon-search" type="primary" style="float: right;margin-left: 10px" @click="dialogFormVisible = true">高级搜索</el-button>
                 <el-dialog title="高级搜索" style="text-align: left" width="70%" :visible.sync="dialogFormVisible">
                    <div>   
                 <el-form :inline="true" label-width="100px"  size="small" :model="dataForm" class="demo-form-inline">
                 <el-row>
                 <el-col :span="8">
                      <el-form-item label="渠道选择:">
                       <el-cascader
                       ref = "cascader"
                       v-model="dataForm.channelCodess"
                        :props="props3"
                        ></el-cascader>
                      </el-form-item>
                      </el-col>
                      <el-col :span="8">
                      <el-form-item label="计划类型选择:">
                       <el-select  style="width:100%" v-model="dataForm.typess" clearable  multiple  placeholder="请选择">
                              <el-option
                                label="营销计划(直营)"
                                value="1">
                              </el-option>
                              <el-option
                                label="营销计划(加盟)"
                                value="2">
                              </el-option>
                              <el-option
                                label="营销计划(云商)"
                                value="3">
                              </el-option>
                              <el-option
                                label="营销计划(APP)"
                                value="4">
                              </el-option>
                              <el-option
                                label="新开店计划(加盟)"
                                value="5">
                              </el-option>
                              <el-option
                                label="新开店计划(直营)"
                                value="6">
                              </el-option>
                              <el-option
                                label="新品铺货计划(直营)"
                                value="7">
                              </el-option>
                              <el-option
                                label="新品铺货计划(云商)"
                                value="8">
                              </el-option>
                              <el-option
                                label="新品铺货计划(APP)"
                                value="9">
                              </el-option>
                              <el-option
                                label="新品铺货计划(经销中心)"
                                value="10">
                              </el-option>
                              <el-option
                                label="销售计划(加盟)"
                                value="11">
                              </el-option>
                              <el-option
                                label="销售计划(APP)"
                                value="12">
                              </el-option>
                              <el-option
                                label="销售计划(经销中心)"
                                value="13">
                              </el-option>
                              <el-option
                                label="销售计划(云商)"
                                value="14">
                              </el-option>
                              <el-option
                                label="新品铺货计划(加盟)"
                                value="15">
                              </el-option>
                              <el-option
                                label="销售计划(直营)"
                                value="16">
                              </el-option>
                              </el-select>
                      </el-form-item>
                      </el-col>
                      <el-col :span="8">
                      <el-form-item label="区域选择:">
                     <el-cascader
                     v-model="dataForm.areaCodes"
                    :props="props2"
                    ></el-cascader>
                      </el-form-item>
                      </el-col>
                      </el-row>
                      <el-row>
                      <el-col :span="8">
                      <el-form-item label="商品选择:">
                          <el-cascader :props="props1" v-model="dataForm.categoryCodess" ref="tree" ></el-cascader>
                      </el-form-item>
                      </el-col>
                      <el-col :span="8">
                              <el-form-item label="商品编码:">
                              <el-input type="textarea"
  :autosize="{ minRows: 1, maxRows: 4}" style="width:210px;" placeholder="请输入商品编码"
  v-model="dataForm.skuCodeS"
  clearable></el-input>
</el-form-item>
</el-col></el-row> 

                            <!--<el-row>
                              <el-col :span="24">
                              <el-form-item label="分层类型:" v-show="(dataForm.channelCodess && dataForm.channelCodess.length) || (dataForm.areaCodes && dataForm.areaCodes.length)">
                                    <el-select  style="width:100%" @change="dataForm.layeredCodess = []" v-model="dataForm.randType" clearable placeholder="请选择">
                                        <el-option label="销量分层" value="sale"></el-option>
                                        <el-option label="销售额分层" value="amount"></el-option>
                                    </el-select>
                                </el-form-item>
                                </el-col>
                                <el-col :span="24">
                              <el-form-item label="商品分层:" v-show="((dataForm.channelCodess && dataForm.channelCodess.length) || (dataForm.areaCodes && dataForm.areaCodes.length)) && dataForm.randType && dataForm.randType.length">
                                <el-checkbox-group v-model="dataForm.layeredCodess">
                                             <el-checkbox label="A">A</el-checkbox>
                                             <el-checkbox label="B">B</el-checkbox>
                                             <el-checkbox label="C">C</el-checkbox>
                                             <el-checkbox label="D">D</el-checkbox>
                              </el-checkbox-group>
                              </el-form-item>
                              </el-col></el-row>-->
                              <el-row>
                              <el-col :span="24">
                                  <el-form-item label="指标选择:">
                                        <el-checkbox-group v-model="dataForm.quota11">
                                        <el-row>
                                            <el-col :span="6"  v-for="item in targetOption">
                                             <el-checkbox :key="item.value" :label="item.value">{{ item.label }}</el-checkbox></el-col>
                                        </el-row>
                                        </el-checkbox-group>
                                  </el-form-item>
                              </el-col>
                              </el-row>
                            </el-form>
                        </el-row>
                        <div slot="footer" style="text-align: center">
                            <span class="dialog-footer">
                            <el-button size="mini" @click="clearCondition">清 除 条 件</el-button>
                            <el-button type="primary" size="mini" @click="searchList">搜 索</el-button>
                          </span>
                        </div>  
                    </div>
                  </el-dialog>
                  <el-button size="small" type="primary" style="margin-right: 5px"  @click="choiceAllocationDetail">任务列表</el-button>
                  <el-dropdown @command="commandUnit">
                      <el-button type="info" size="small" style="margin-right: 5px">
                        {{defaultUnit?defaultUnit:defaultUnitItem.name}}<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item v-for="item in unitOption" :command="item">{{item.unitName}}</el-dropdown-item>                      
                      </el-dropdown-menu>
                    </el-dropdown>
                 <el-button @click="confirmNum()" size="small" type="primary" style="margin-right: 5px">确认</el-button>
                    <el-dropdown v-if="isAuth('scm-plan:other-channel:import')"   @command="handleCommand">
                  <el-button :disabled="importStatus" size="small" type="primary" style="margin-right: 5px">
                    导入<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                  <!--<el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-for="item in otherImpTypeLists" :command="item.type">{{item.typeName}}</el-dropdown-item> 
                  </el-dropdown-menu>-->
                  <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item :command="11">销售计划(加盟)</el-dropdown-item>
                        <el-dropdown-item :command="12">销售计划(APP)</el-dropdown-item>
                        <el-dropdown-item :command="13">销售计划(经销中心)</el-dropdown-item>
                        <el-dropdown-item :command="14">销售计划(云商)</el-dropdown-item>
                        <el-dropdown-item :command="15">新开店计划</el-dropdown-item>
                        <el-dropdown-item :command="16">新品铺货计划</el-dropdown-item>
                        <el-dropdown-item :command="17">销售计划(直营)</el-dropdown-item>
                      </el-dropdown-menu>
                </el-dropdown>
             <el-dropdown @command="command">
                  <el-button type="primary"  size="small">
                    导出<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                  <el-dropdown-menu  slot="dropdown">
                    <el-dropdown-item :command="1">当前页数据</el-dropdown-item>
                    <el-dropdown-item :command="2">已勾选数据</el-dropdown-item>
                    <el-dropdown-item :command="3">所有查询结果</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
                
             </div>
              </div>
              
              <el-dialog :title="titleText" :visible.sync="dialogVisible3" :close-on-click-modal="false" :beforeClose="handleClose" width="700px">
                    <el-steps :active="activeStep" align-center>
                        <el-step title="上传文档"></el-step>
                        <el-step title="导入并校验"></el-step>
                        <el-step title="创建完成"></el-step>
                    </el-steps>
                    <div v-show="activeStep !== 3">
                        1.<el-button type="text">点击<a href="javascript:void(0)" @click="downLodeTemplate" style="color:#17b3a3;">下载导入数据模板</a></el-button>将要导入的数据填充到数据导入模板文件中。
                        <div>
                            <div style="color:red;">注意事项:</div>
                            <p>（1）模板中的标题不可更改，标题行不可删除；</p>
                            <p>（2）导入文件不能包含“合并单元格”，否则无法导入；</p>
                            <p>（3）单次导入的数据不超过10000条；</p>
                            <p>（4）每次导入必须下载模板导入；</p>
                        </div>
                    </div>
                    <div v-show="activeStep === 1">
                        2. 请选择要导入的数据文件。
                        <el-upload :on-change="handleChangeUpload" accept=".xls,.xlsx" :show-file-list="false" :auto-upload="false" class="upload-demo" style="padding:5px 18px;" action="https://jsonplaceholder.typicode.com/posts/" :limit="1" :file-list="fileList">
                            <el-button size="small" type="primary"><i class="el-icon-plus"></i>&nbsp;选择文件</el-button>
                            <div slot="tip" class="el-upload__tip" style="color:#ccc;">请选择excel文件，允许上传附件类型（xls,xlsx），文件大小不得大于1MB</div>
                        </el-upload>
                    </div>
                    <div class="file-list" v-show="fileList.length > 0">
                        <div class="file-list__item" style="marginTop:20px;padding:10px 20px;backgroundColor: #eaeaea;display:flex;justifyContent: space-between;" v-for="item in fileList" :key="item.name">
                            <div>{{item.name}}</div>
                            <div>{{(item.size/1024).toFixed(2)}}KB</div>
                            <div>完成</div>
                        </div>
                    </div>
                    <div slot="footer" class="dialog-footer" style="text-align:center;">
                        <el-button type="primary" @click.native="submitUpload" :disabled="activeStep===1 || (importErrInfo != '' && importErrInfo != null)" v-show="activeStep !==3">开始导入</el-button>
                        <el-button @click.native="onClickCancelBtn" v-show="activeStep !==3">{{cancelBtnText}}</el-button>
                        <el-button @click.native="onClickCancelBtn" v-show="activeStep ===3">关闭</el-button>
                    </div>
                    <p style="text-align: center;color:red;margin-top:10px;" v-if="activeStep === 2 && (importErrInfo != '' && importErrInfo != null)">{{importErrInfo}}</p>
                </el-dialog>
              
              
              
            <time-line ref="timeLine" @offsetFun="offsetFun"></time-line>
             <el-table v-loading="dataListLoading" v-if="dataList.length === 0 "></el-table>
             
             <!--@selection-change="handleSelectionChange"-->
             
            <el-table
                :data="dataList"
                :span-method="arraySpanMethod"
                @select="selectChange"
                @select-all="selectAllChange"
                center
                ref="table"
                v-if="dataList.length"
                border
                v-loading="dataListLoading"
                highlight-current-rows
                height="33vh"
                :header-row-style="{height: '20px',fontSize: '14px', fontWeight: '700',lineHeight: '36px',textAlign: 'center',backgroundColor: '#f3f4f4',padding: 0}"
                :row-style="{ color: '#999A9A', height: '16px',fontSize: '12px', fontWeight: 400,lineHeight: '26px',textAlign: 'center'}"
                :cell-style="{padding: 0}"
                  :header-cell-style="findStyle"
                style="width: 100%;padding: 0"
                :highlight-current-row="false">
            <el-table-column
                    type="selection"
                     fixed="left"
                    width="55">
            </el-table-column>
            <el-table-column
            width="80"
                  prop="channel"
                  fixed="left"
                  label="渠道" align="left">
                  <template slot-scope="scope">
                      {{scope.row.channel}}
                    </template>
                </el-table-column>
                <el-table-column
            width="80"
                  prop="type"
                  fixed="left"
                  label="计划类型" align="left">
                  <template slot-scope="scope">
                      {{scope.row.type}}
                    </template>
                </el-table-column>
                <el-table-column
                width="90"
                  prop="area"
                  fixed="left"
                  label="区域" align="left">
                   <template slot-scope="scope">
                        {{scope.row.area}}
                    </template>
                </el-table-column>
               
                <el-table-column
                  prop="category"
                  width="90"
                  fixed="left"
                  label="品类" align="left">
                </el-table-column>
                <el-table-column
                  prop="skuName"
                  fixed="left"
                  width="90"
                  label="商品" align="left">
                </el-table-column>
                <!--<el-table-column
                  prop="latestArrivalDate"
                  fixed="left"
                  width="120"
                  label="最晚到货日期" align="left">
                  <template slot-scope="scope">
                      {{scope.row.latestArrivalDate}}
                  </template>
                </el-table-column>-->
                <el-table-column
                width="135"
                fixed="left"
                  prop="planConfirmLabel" label="指标" align="left">
                   <template slot-scope="scope">
                         <el-tooltip class="item" effect="dark" :content="indexContent(scope.row.planConfirmLabel)" placement="top">
                          <span>{{ scope.row.planConfirmLabel }}</span>
                        </el-tooltip>
              </template>
                </el-table-column>
            <el-table-column
                v-for="(week, index) in weekDate"
              :label="week" width="120" align="right">
              <template slot-scope="scope">
                  <el-input v-if="confirmStatus && scope.row.isInput && scope.row.statusStu[index] == 1 && (scope.row.typeStu[index] == 11 || scope.row.typeStu[index] == 12 || scope.row.typeStu[index] == 13 || scope.row.typeStu[index] == 14 || scope.row.typeStu[index] == 16)" size="small"   type = "number" :style="{textAlign: 'right'}" v-model="scope.row.confirmedQtys[index]"></el-input>
                  <span v-else>{{scope.row.confirmedQtys[index] == 0? '-' : scope.row.confirmedQtys[index] }}</span>
              </template>
            </el-table-column>
        </el-table>
            <div style=";width: 100%;">
                <div style="height: 30px;width: 1px"></div>
                <el-row>
                 <span style="margin-left: 20px">日期范围</span>
                <el-date-picker
                  v-model="valuea"
                  @change="changePicker"
                  type="daterange"
                  size="small"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  align="right"
                  unlink-panels
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  :picker-options="pickerOptions">  
                </el-date-picker>
                <el-select v-model="values" size="small" clearable collapse-tags :multiple-limit="4" multiple placeholder="请选择指标" @change="labelChange">
                    <el-option
                      v-for="item in labels"
                      :key="item"
                      :label="item"
                      :value="item">
                    </el-option>
                  </el-select>
                 <el-pagination
                 background
                 @size-change="sizeChangeHandle"
                 @current-change="currentChangeHandle"
                 :current-page="pageIndex"
                 :page-sizes="[10, 20, 30, 50]"
                 :page-size="pageSize"
                 :total="totalCount"
                  small
                  style="float: right"
                  layout="sizes, prev, pager, next">
                </el-pagination>
                </el-row>
                <div v-loading="echartsLoading" style="margin-top: 20px;height: 30vh;width: 100%;" id="echarts"></div>
            </div>
            </el-card>
        <el-dialog
          center
          :style="{ padding: '0px' }"
          fullscreen
          :show-close="false"
          :visible.sync="dialogVisible1">
           <div style="">
           <div style="text-align: right;margin: 5px">
           <el-button size="small" style="float: left;margin-left: 10px" @click="leaveFullScreen">退出全屏</el-button>
           <el-button size="small"  icon="el-icon-search" type="primary" style="float: right;margin-left: 10px" @click="dialogFormVisible = true">高级搜索</el-button>
                 <el-dialog title="高级搜索" append-to-body width="70%" :visible.sync="dialogFormVisible">
                    <div>   
                 <el-form :inline="true" label-width="100px"  size="small" :model="dataForm" class="demo-form-inline">
                 <el-row>
                 <el-col :span="8">
                      <el-form-item label="渠道选择:">
                       <el-cascader
                       ref = "cascader"
                       v-model="dataForm.channelCodess"
                        :props="props3"
                        ></el-cascader>
                      </el-form-item>
                      </el-col>
                      <el-col :span="8">
                      <el-form-item label="计划类型选择:">
                       <el-select  style="width:100%" v-model="dataForm.typess" clearable  multiple  placeholder="请选择">
                              <!--<el-option
                                v-for="item in otherTypeLists"
                                :key="item.type"
                                :label="item.typeName"
                                :value="item.type">
                              </el-option>-->
                              
                              <el-option
                                label="营销计划(直营)"
                                value="1">
                              </el-option>
                              <el-option
                                label="营销计划(加盟)"
                                value="2">
                              </el-option>
                              <el-option
                                label="营销计划(云商)"
                                value="3">
                              </el-option>
                              <el-option
                                label="营销计划(APP)"
                                value="4">
                              </el-option>
                              <el-option
                                label="新开店计划(加盟)"
                                value="5">
                              </el-option>
                              <el-option
                                label="新开店计划(直营)"
                                value="6">
                              </el-option>
                              <el-option
                                label="新品铺货计划(直营)"
                                value="7">
                              </el-option>
                              <el-option
                                label="新品铺货计划(云商)"
                                value="8">
                              </el-option>
                              <el-option
                                label="新品铺货计划(APP)"
                                value="9">
                              </el-option>
                              <el-option
                                label="新品铺货计划(经销中心)"
                                value="10">
                              </el-option>
                              <el-option
                                label="销售计划(加盟)"
                                value="11">
                              </el-option>
                              <el-option
                                label="销售计划(APP)"
                                value="12">
                              </el-option>
                              <el-option
                                label="销售计划(经销中心)"
                                value="13">
                              </el-option>
                              <el-option
                                label="销售计划(云商)"
                                value="14">
                              </el-option>
                              <el-option
                                label="新品铺货计划(加盟)"
                                value="15">
                              </el-option>
                              <el-option
                                label="销售计划(直营)"
                                value="16">
                              </el-option>
                              </el-select>
                      </el-form-item>
                      </el-col>
                      <el-col :span="8">
                      <el-form-item label="区域选择:">
                     <el-cascader
                     v-model="dataForm.areaCodes"
                    :props="props2"
                    ></el-cascader>
                      </el-form-item>
                      </el-col>
                      </el-row>
                      <el-row>
                      <el-col :span="8">
                      <el-form-item label="商品选择:">
                          <el-cascader :props="props1" v-model="dataForm.categoryCodess" ref="tree" ></el-cascader>
                      </el-form-item>
                      </el-col>
                      <el-col :span="8">
                              <el-form-item label="商品编码:">
                              <el-input type="textarea"
  :autosize="{ minRows: 1, maxRows: 4}" style="width:210px;" placeholder="请输入商品编码"
  v-model="dataForm.skuCodeS"
  clearable></el-input>
</el-form-item>
</el-col></el-row>
<!--<el-row>
                              <el-col :span="24">
                              <el-form-item label="分层类型:" v-show="(dataForm.channelCodess && dataForm.channelCodess.length)">
                                    <el-select  style="width:100%" v-model="dataForm.randType" clearable placeholder="请选择">
                                        <el-option label="销量分层" value="sale"></el-option>
                                        <el-option label="销售额分层" value="amount"></el-option>
                                    </el-select>
                                </el-form-item>
                                </el-col>
                                <el-col :span="24">
                              <el-form-item label="商品分层:" v-show="dataForm.randType && dataForm.randType.length">
                                <el-checkbox-group v-model="dataForm.layeredCodess">
                                             <el-checkbox label="A">A</el-checkbox>
                                             <el-checkbox label="B">B</el-checkbox>
                                             <el-checkbox label="C">C</el-checkbox>
                                             <el-checkbox label="D">D</el-checkbox>
                              </el-checkbox-group>
                              </el-form-item>
                              </el-col></el-row>--><el-row>
                              <el-col :span="24">
                                  <el-form-item label="指标选择:">
                                        <el-checkbox-group v-model="dataForm.quota11">
                                        <el-row>
                                            <el-col :span="6"  v-for="item in targetOption">
                                             <el-checkbox :key="item.value" :label="item.value">{{ item.label }}</el-checkbox></el-col>
                                        </el-row>
                                        </el-checkbox-group>
                                  </el-form-item>
                              </el-col>
                              </el-row>
                            </el-form>
                        </el-row>
                        <div slot="footer" style="text-align: center">
                            <span class="dialog-footer">
                            <el-button size="mini" @click="clearCondition">清 除 条 件</el-button>
                            <el-button type="primary" size="mini" @click="searchList">搜 索</el-button>
                          </span>
                        </div>  
                    </div>
                  </el-dialog>
                  <el-button size="small" type="primary" style="margin-right: 5px"  @click="choiceAllocationDetail">任务列表</el-button>
                  <el-dropdown @command="commandUnit">
                      <el-button type="info" size="small" style="margin-right: 5px">
                        {{defaultUnit?defaultUnit:defaultUnitItem.name}}<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                      <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item v-for="item in unitOption" :command="item">{{item.unitName}}</el-dropdown-item>                      
                      </el-dropdown-menu>
                    </el-dropdown>
                 <el-button @click="confirmNum()" size="small" type="primary"  style="margin-right: 5px">确认</el-button>
                    <el-dropdown v-if="isAuth('scm-plan:other-channel:import')" @command="handleCommand" >
                  <el-button :disabled="importStatus" size="small" type="primary" style="margin-right: 5px" >
                    导入<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                  <!--<el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-for="item in otherImpTypeLists" :command="item.type">{{item.typeName}}</el-dropdown-item> 
                  </el-dropdown-menu>-->
                  <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item :command="11">销售计划(加盟)</el-dropdown-item>
                        <el-dropdown-item :command="12">销售计划(APP)</el-dropdown-item>
                        <el-dropdown-item :command="13">销售计划(经销中心)</el-dropdown-item>
                        <el-dropdown-item :command="14">销售计划(云商)</el-dropdown-item>
                        <el-dropdown-item :command="15">新开店计划</el-dropdown-item>
                        <el-dropdown-item :command="16">新品铺货计划</el-dropdown-item>
                        <el-dropdown-item :command="17">销售计划(直营)</el-dropdown-item>
                      </el-dropdown-menu>
                </el-dropdown>
                
                
             <el-dropdown @command="command">
                  <el-button type="primary"  size="small">
                    导出<i class="el-icon-arrow-down el-icon--right"></i></el-button>
                  <el-dropdown-menu  slot="dropdown">
                    <el-dropdown-item :command="1">当前页数据</el-dropdown-item>
                    <el-dropdown-item :command="2">已勾选数据</el-dropdown-item>
                    <el-dropdown-item :command="3">所有查询结果</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
                  </div>
                  <el-table v-loading="dataListLoading" v-if="dataList.length === 0 "></el-table>
                <el-table
                :data="dataList"
                :span-method="arraySpanMethod"
                @select="selectChange"
                @select-all="selectAllChange"
                center
                ref="tablemax"
                border
                   v-if="dataList.length"
                v-loading="dataListLoading"
                highlight-current-rows
                height="85vh"
                :header-row-style="{height: '20px',fontSize: '14px', fontWeight: '700',lineHeight: '36px',textAlign: 'center',backgroundColor: '#f3f4f4',padding: 0}"
                :row-style="{ color: '#999A9A', height: '16px',fontSize: '12px', fontWeight: 400,lineHeight: '26px',textAlign: 'center'}"
                :cell-style="{padding: 0}"
                  :header-cell-style="findStyle"
                style="width: 100%;padding: 0"
                :highlight-current-row="false">
            <el-table-column
                    type="selection"
                     fixed="left"
                    width="55">
            </el-table-column>
            <el-table-column
            width="130"
                  prop="channel"
                  fixed="left"
                  label="渠道" align="left">
                  <template slot-scope="scope">
                      {{scope.row.channel}}
                    </template>
                </el-table-column>
                <el-table-column
            width="130"
                  prop="type"
                  fixed="left"
                  label="计划类型" align="left">
                  <template slot-scope="scope">
                      {{scope.row.type}}
                    </template>
                </el-table-column>
                <el-table-column
                width="130"
                  prop="area"
                  fixed="left"
                  label="区域" align="left">
                   <template slot-scope="scope">
                        {{scope.row.area}}
                    </template>
                </el-table-column>
                <el-table-column
                  prop="category"
                  width="130"
                  fixed="left"
                  label="品类" align="left">
                </el-table-column>
                
                <el-table-column
                  prop="skuName"
                  fixed="left"
                  width="130"
                  label="商品" align="left" >
                </el-table-column>
                <!--<el-table-column
                  prop="latestArrivalDate"
                  fixed="left"
                  width="120"
                  label="最晚到货日期" align="left">
                  <template slot-scope="scope">
                      {{scope.row.latestArrivalDate}}
                  </template>
                </el-table-column>-->
                <el-table-column
                width="135"
                fixed="left"
                  prop="planConfirmLabel" label="指标" align="left">
                   <template slot-scope="scope">
                         <el-tooltip class="item" effect="dark" :content="indexContent(scope.row.planConfirmLabel)" placement="top">
                          <span>{{ scope.row.planConfirmLabel }}</span>
                        </el-tooltip>
              </template>
                </el-table-column>
            <el-table-column
                v-for="(week, index) in weekDate"
              :label="week" width="120" align="right">
              <template slot-scope="scope">
                  <el-input v-if="confirmStatus && scope.row.isInput && scope.row.statusStu[index] == 1 && (scope.row.typeStu[index] == 11 || scope.row.typeStu[index] == 12 || scope.row.typeStu[index] == 13 || scope.row.typeStu[index] == 14 || scope.row.typeStu[index] == 16)" size="small"   type = "number" :style="{textAlign: 'right'}" v-model="scope.row.confirmedQtys[index]"></el-input>
                  <span v-else>{{scope.row.confirmedQtys[index] == 0? '-' : scope.row.confirmedQtys[index] }}</span>
              </template>
            </el-table-column>
        </el-table>
          <el-pagination
          background
                 @size-change="sizeChangeHandle"
                 @current-change="currentChangeHandle"
                 :current-page="pageIndex"
                 :page-sizes="[10, 20, 30, 50]"
                 :page-size="pageSize"
                 :total="totalCount"
                  small
                  style="float: right"
                  layout="sizes, prev, pager, next">
                </el-pagination>
           </div>
          <span slot="footer" class="dialog-footer">
          </span>
        </el-dialog>

    </div>
    `
        }
    );
});